PICTools Programmer's Reference
Auto Border Crop

Detects and optionally removes a scan border from an image. A scan border is any border that was added by a scanning process. This subcode assumes that the border to be removed is dark, while the page is light. The border will be detected during REQ_INIT and removed during REQ_EXEC.

Occasionally, a border will not be detected. In those cases, the confidence of the detection will usually be low and the caller will usually skip the call to REQ_EXEC.

A number of parameters can be used to control the border detection process. While the detection process is tolerant of incorrect control values, setting these values correctly will provide more accurate results. In particular, setting a tight limit on the width and height of the page will produce more accurate results.

There are three options for removing a border: deskew, fill, and crop. Each can be used independently or in conjunction with the rest. At least one must be set to true.

Setting u.SC21.DeskewBorder to true will cause the output image to be deskewed, based on the angle of the detected border. In some cases, the content of a page will be skewed differently from the edge of the page. This subcode ignores the skew of the content of the page.

Setting u.SC21.ReplaceBorder to true will cause the border pixels to be replaced with new pixels, whose color matches PadColor.

Setting u.SC21.RemoveBorder to true will cause the border pixels to be removed from the image.

The images below demonstrate the operation of the subcode using various combinations of the above parameters.

CropInput  → (deskew)  Crop-Deskewed

CropInput  → (remove)  Crop-Crop

CropInput  → (replace)  Crop-Fill

CropInput  → (deskew & replace)  Crop-DeskewedFill

CropInput  → (deskew & remove)  Crop-DeskewedCrop

CropInput  → (replace and remove)  Crop-CropFill

CropInput  → (deskew, remove, and replace)  Crop-DeskewedCropFill

This subcode is unlike the other subcodes, in that it performs significant work during both REQ_INIT and REQ_EXEC. During REQ_INIT, it will read the image and examine it to find the border. At this time, it will also determine the size of the output image. During REQ_EXEC, it will again read the image and then crop and deskew the image to remove the border which was detected during REQ_INIT. All input values must be set before REQ_INIT. In some cases (such as u.SC21.DeskewImage), the operation will not be applied until REQ_EXEC, but the value is also used by REQ_INIT to determine the size of the output image.

The uncompressed image to be processed must reside in the Get Queue prior to both REQ_INIT and REQ_EXEC. Typically, the image will be fully contained in the Get Queue, but that is not a requirement. The output image will be placed into the Put Queue during REQ_EXEC.

The uncompressed image must be a minimum of 64x64 pixels or the error code ERR_BAD_MIN_SIZE will be returned during REQ_INIT.

Padding pixels present at the end of each line may be modified by this operation.

In addition to placing an output image into the Put Queue, this operation stores some output information into the PIC_PARM structure in the following locations.

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback